import { http } from '@/server'
import type { HttpResponsePromise } from '@/server/interface'
import type * as I from './interface'

// 获取班级list
export const getClassList = (params: I.GetClassList.Req): HttpResponsePromise<I.GetClassList.Res> =>
    http.get('/engineer/group/list', { params })

// 获取培训计划list
export const getTrainList = (params: I.GetTrainList.Req): HttpResponsePromise<I.GetTrainList.Res> =>
    http.get('/engineer/plan', { params }) //  engineer/plan/list

// 获取培训计划详情
export const queryTrainDetail = (id: number): HttpResponsePromise<I.GetTrainList.Res> =>
    http.get(`/engineer/plan/info/${id}`)

/**
 * 获取字典数据
 * @param type
 * @returns
 */
export const fetchDict = (type: I.Dictionary.Type): HttpResponsePromise<I.Dictionary.Res> =>
    http.get('/books', { params: { code: type } })

/**
 * 获取 培训计划
 * @param params
 * @returns
 */
export const getPlanInfo = (params: I.GetPlan.Params): HttpResponsePromise<I.GetPlan.Res> =>
    http.get('/engineer/plan/info/' + params.id)

/**
 * 审核 培训信息
 * @param params
 * @returns
 */
export const checkPlan = (
    params: I.CheckPlan.Params,
    body: I.CheckPlan.Body,
): HttpResponsePromise<I.CheckPlan.Res> => http.post('/engineer/plan/check/' + params.id, body)
